home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-07-28 | 2.2 KB | 120 lines | [TEXT/MPS ] |
- /*
- File: BuildingBlocksTest.cp
-
- Copyright: © 1991-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Part of the AOCE Sample SMSAM Package. Consult the license
- which came with this software for your specific legal rights.
-
- */
-
-
-
- #ifndef __BUILDINGBLOCKSTEST__
- #include "BuildingBlocksTest.h"
- #endif
-
- #ifndef __STRING__
- #include "String.h"
- #endif
-
- #ifndef __TOOLUTILS__
- #include "ToolUtils.h"
- #endif
-
- #ifndef __STDLIB__
- #include "StdLib.h"
- #endif
-
- #ifndef __MEMORY__
- #include "Memory.h"
- #endif
-
- #pragma segment BuildingBlocksTests
-
- /***********************************|****************************************/
-
- #ifdef BLJTestTool
-
- #ifndef __CURSORCTL__
- #include "CursorCtl.h"
- #endif
-
- void Busy ( short s )
- {
- SpinCursor ( s );
- }
-
- #else
-
- void Busy ( short )
- {
- }
-
- #endif
-
- /***********************************|****************************************/
- /***********************************|****************************************/
-
- CLeakChecker::CLeakChecker ( ostream& stream ):
- fReportTo ( stream ),
- fRememberedFree ( GetFreeBytes () )
- {
- }
-
- /***********************************|****************************************/
-
- CLeakChecker::~CLeakChecker ()
- {
- ReportIfChanged ();
- }
-
- /***********************************|****************************************/
-
- ostream&
- CLeakChecker::operator >> ( ostream& stream ) const
- {
- return stream << "current: " << GetFreeBytes () << ", delta: " << GetDelta () << '\n';
- }
-
- /***********************************|****************************************/
-
- void
- CLeakChecker::ReportIfChanged ()
- {
- long delta = GetDelta ();
-
- if ( delta != 0 )
- {
- fReportTo << "••• CLeakChecker Report: HEAP GREW BY " << delta << " BYTES!\n" << flush;
- }
- }
-
- /***********************************|****************************************/
-
- void
- CLeakChecker::Remember ()
- {
- fRememberedFree = GetFreeBytes ();
- }
-
- /***********************************|****************************************/
-
- unsigned long
- CLeakChecker::GetFreeBytes () const
- {
- CompactMem ( maxSize );
- return FreeMem ();
- }
-
- /***********************************|****************************************/
-
- long
- CLeakChecker::GetDelta () const
- {
- return (long) fRememberedFree - (long) GetFreeBytes ();
- }
-
- /***********************************|****************************************/
-